package Heap;

/*
 *@Student 张策
 */
public class BigHeap_ {
    int[]elem;
    public int  useSize;

    public BigHeap_() {
        this.elem = new int[10];
    }

    public void cread(int[]arr){
        for (int i = 0; i < elem.length; i++) {
            elem[i]=arr[i];
            useSize++;
        }
    }
    public void Big(){
        for (int pare = (useSize-1-1)/2; pare >=0; pare--) {
            siftDown(pare,useSize);
        }
    }
    private void siftDown(int parent,int end){
        int child=parent*2+1;
        while (child<end){
            if (child+1<end&&elem[child]<elem[child+1]){
                child++;
            }
            if(elem[parent]<elem[child]){
                swap(parent,child);
                parent = child;
                child = 2*parent+1;
            }else {
                break;
            }
        }
    }
    private void swap(int a,int b){
        int tem=elem[a];
        elem[a]=elem[b];
        elem[b]=tem;
    }
}
